<template>
  <el-form class="login-container" label-position="left" label-width="0px">
    <h3 class="login_title">系统登入</h3>
    <el-form-item>
      <el-input type="text" v-model="loginForm.username"
                auto-complete="off" aria-placeholder="账号"></el-input>
    </el-form-item>
    <el-form-item>
      <el-input type="password" v-model="loginForm.password"
                auto-complete="off" aria-placeholder="密码"></el-input>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" style="width: 100%;background: #505458; border: none"
                 v-on:click="login">登入</el-button>
    </el-form-item>
  </el-form>

</template>

<script>
    export default {
      name: "Login",
      data(){
        return {
          loginForm:{
            username: '',
            password: ''
          },
          responseResult: []
        }
      },
      methods: {
        login(){
          this.$axios
            .post('/login',{
              username: this.loginForm.username,
              password: this.loginForm.password
            })
            .then(result => {
              if(result.data.code == 200){
                console.log(result);
                /*
                *  1、query 传参使用 path
                *  2、params 传送使用 name
                *
                * */
                /*this.$router.replace({path: '/index', query:{token: result.data.data}});*/
                this.$router.replace({name: 'AppIndex', params:{token: result.data.data}});
              }
            })
            .catch(result => {
              console.log(result);
            })
        }
      }
    }
</script>

<style scoped>
  .login-container {
    border-radius: 15px;
    background-clip: padding-box;
    margin: 90px auto;
    width: 350px;
    padding: 35px 35px 15px 35px;
    background: #fff;
    border: 1px solid #eaeaea;
    box-shadow: 0 0 25px #cac6c6;
  }

  .login_title {
    margin: 0px auto 40px auto;
    text-align: center;
    color: #505458;
  }
</style>
